function y = hgmm_classify_cluster(X, hgmm)

num_clusters = size(hgmm.cluster_model, 1);
num_points = size(X, 1);
y = zeros(num_points, 1);


best_logp = gmm_logpdf(X, hgmm.cluster_model{1}) + log(hgmm.cluster_prior(1));
y(1) = hgmm.cluster_label(1);

for j = 2 : num_clusters
    fprintf('Calculating probabilities for cluster %d\n', hgmm.cluster_label(j));
    cur_logp = gmm_logpdf(X, hgmm.cluster_model{j}) + log(hgmm.cluster_prior(j));
    for i = 1 : num_points
        if (cur_logp(i) > best_logp(i))
            y(i) = hgmm.cluster_label(j);
            best_logp(i) = cur_logp(i);
        end
    end
end

